﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace SocketTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string message = string.Empty;
            System.Net.IPHostEntry ipHost = Dns.Resolve("127.0.0.1");
            IPAddress ipAddress = ipHost.AddressList[0];
            IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 5555);
            Socket sender = new Socket(AddressFamily.InterNetwork,
                                        SocketType.Stream,
                                        ProtocolType.Tcp);
            sender.Connect(ipEndPoint);
            while (message != "exit")
            {
                message= Console.ReadLine();
                if (message == "exit")
                    break;
                byte[] arrayToSend = Encoding.ASCII.GetBytes(message + "[END]"); ;
                sender.Send(arrayToSend);
            }
            sender.Shutdown(SocketShutdown.Both);
            sender.Close();
            
        }
    }
}
